package ${package.ComposeService};

<#------------ BEGIN 导包 ------------>
<#list table.composeServiceImportPackages as pkg>
import ${pkg};
</#list>

import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.io.Serializable;

<#------------ END   导包 ------------>

/**
 * <#if table.comment??>${table.comment!} </#if>聚合服务
 *
 * @author ${author}
 * @since ${date}
 */
@Service
@AllArgsConstructor
public class ${composeService} {

<#if composeServiceField>
    private final ${table.serviceName} service;
</#if>
<#------------ BEGIN list ---------->
<#if composeServiceListMethod>
    /**
     * 列表查询
     *
     * @param request 参数
     * @return list
     */
    public List<${vo}> list(${request} request) {
        return service.list(request.transform())
                .stream()
                .map(${vo}::new)
                .collect(Collectors.toList());
    }

</#if>
<#------------ END list ---------->
<#------------ BEGIN page ---------->
<#if composeServicePageMethod>
    /**
     * 分页查询
     *
     * @param request 参数
     * @return page
     */
    public IPage<${vo}> page(${pageRequest} request) {
        return service.page(request, request.transform()).convert(${vo}::new);
    }

</#if>
<#------------ END   page ---------->
<#------------ BEGIN getVO ---------->
<#if composeServiceGetMethod>
    /**
     * 详情 根据主键
     *
     * @param id id
     * @return 详情
     */
    public ${vo} getVoById(Serializable id) {
        return new ${vo}(service.getById(id));
    }

</#if>
<#------------ END   getVO ---------->
<#------------ BEGIN delete ---------->
<#if composeServiceDeleteMethod>

    /**
     * 删除 根据主键
     *
     * @param id id
     * @return flag
     */
    public boolean deleteById(Serializable id) {
        return service.removeById(id);
    }

</#if>
<#------------ END   delete ---------->
}